package org.abacus.client.ui.access;

import java.awt.Toolkit;

import org.abacus.client.config.layout.GridDataConfig;
import org.abacus.client.config.layout.GridLayoutConfig;
import org.abacus.client.config.layout.LayoutConfig;
import org.abacus.client.config.layout.LayoutDataConfig;
import org.abacus.client.config.widgets.ViewConfig;
import org.abacus.client.config.widgets.ViewConfigType;
import org.abacus.client.ui.control.widgets.WidgetProvider;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;

public abstract class AccessDataFactory {
	public static synchronized AccessDataFactory getInstance() {
		return new AccessDataFactoryImpl();
	}

	public abstract AccessData createAccessData(String id, WidgetProvider widgetProvider);

	public abstract void createAccessData(String[] ids, AccessData ad);

	public abstract AccessData createAccessData(String id, Widget widget);

	public abstract AccessData createAccessData(String id, Display display);

	public abstract AccessData createAccessData(ViewConfig viewConfig, Widget widget);

	public abstract AccessData createAccessData(ViewConfig viewConfig, Display display);

	public abstract AccessData createAccessData(ViewConfigType viewConfigType, int style, Widget widget);

	public abstract AccessData createAccessData(ViewConfigType viewConfigType, int style, Display display);

	public abstract GridDataConfig getGridDataConfig(GridData gdc);

	public abstract GridLayoutConfig getGridLayoutConfig(GridLayout glc);

	public abstract Object getLayoutData(LayoutDataConfig layoutDataConfig);

	public abstract Layout getLayout(LayoutConfig layoutConfig);

	public abstract ViewConfig getViewConfig(Class<? extends Widget> keyClazz);

	public final static void centerShell(Shell shell, int width, int height) {
		int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
		int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
		shell.setMinimumSize(width, height);
		shell.setBounds((screenWidth - width) / 2, ((screenHeight - height) / 2), width, height);
	}
}
